package com.github.dwade.shiro.web.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.dwade.shiro.web.entity.User;
import com.github.dwade.shiro.web.sqlmapper.UserMapper;

@Service("userService")
public class UserServiceImpl {

    /**
     * 使用@Autowired注解标注userMapper变量，
     * 当需要使用UserMapper时，Spring就会自动注入UserMapper
     */
    @Autowired
    private UserMapper userMapper;//注入dao

    public void addUser(User user) {
        userMapper.insert(user);
    }

    public User getUserById(Long userId) {
        return userMapper.selectByPrimaryKey(userId);
    }
}